<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>消息弹框</title>
  <link rel="stylesheet" href="res/css/message.css">
  <style>
    body {
      width: 498px;
    }
  </style>
  <script src="res/js/qwebchannel.js"></script>
  <script src="res/js/messageId.js"></script>
</head>

<body>
  <div class="popup-header"></div>
  <div class="info">
    <span class="time" id="sendTime"></span>
    <span class="dept-user" id="sendUser"></span>
  </div>
  <div class="title"></div>
  <div class="content max-line-4" id="content"></div>
  <button class="msg-btn" id="msg-btn" onclick="toView()">查看详情</button>
</body>
<script src="res/js/contextMenu.js"></script>
<script src="res/js/html2Text.js"></script>
<script>
  // 数据接收函数
  var SignalJsResponse  = function (json) {
    let res = JSON.parse(json) || {}
    document.getElementById('sendTime').innerText = res.SendTime
    document.getElementById('sendUser').innerText = res.SendUser
    document.getElementById('content').innerText = Html2Text(res.Content)
  }
  // 调用C++
  new QWebChannel(qt.webChannelTransport, function (channel) {
    var webobj = channel.objects.alert_msg_object;
    window.msg_dlg = webobj;
    window.msg_dlg.SignalJsResponse.connect(SignalJsResponse ); // c++返回内容
    let messageID = GetQueryString('MessageID')
    let data = {
      cmd: 'MainwtMessageDetailReq',
      MessageID: messageID
    }
    msg_dlg.SlotJsRequest(JSON.stringify(data)) // 向c++发送请求
  });

  // 查看详情 请求
  function toView () {
    let messageID = GetQueryString('MessageID')
    let data = {
      cmd: 'MessageDlgDetailReq',
      MessageID: messageID
    }
    msg_dlg.SlotJsRequest(JSON.stringify(data))
  }
</script>

</html>